import axios from 'axios'
import qs from 'qs'
axios.defaults.baseURL = "http://127.0.0.1:5000/"



const maxios = function (url, method, data = {}) {
    return new Promise(resolve => {
        if (method == 'get' || method == 'delete') {
            axios({'url': url, 'method': method, 'params': qs.stringify(data)})
                .then(res => {
                    return resolve(res.data)
                })
        } else {
            axios({'url': url, 'method': method, 'params': qs.stringify(data)})
                .then(res => {
                    return resolve(res.data)
                })
        }
    })

}
export default maxios;